<?php 

class productexpresssku  {




	public function insertbatch($parm){
		try{
			Database::instance()->begin();
			self::delete($parm);
			foreach($parm['skuExpress'] as $key=>$value){
				DB::insert("sysproductexpresssku",array('productId','specificationId','number','freeze','price'))
					->values(array($parm['productId'],$value,$parm['sku'][$key],$parm['freeze'],intval($parm['price'][$key])))
					->execute();
			}
			Database::instance()->commit();
		} catch (Exception $e) {
			echo $e->getMessage();
			Database::instance()->rollback();
			throw $e;
		}
	}
	 	
	public function delete($parm){

   		DB::delete('sysproductexpresssku')->where('productId','=',$parm['productId'])->execute();
	}
	public function get($parm){
		$result = DB::select('*')->from('sysproductexpresssku')->where("productId","=",$parm['id'])->execute()->as_array();
		return $result;
	}

	public function getById($parm){
		$result = DB::select('*')->from('sysproductexpresssku')->where("specificationId","=",$parm['id'])->execute()->as_array();
		return $result;
	}


}